package org.miku.junit;

import static org.junit.Assert.*;

import org.junit.Test;
import org.miku.db.SQLHelper;
import org.miku.module.user.UserInfo;
import org.miku.module.user.UserManager;

public class UserManagerTest {
	SQLHelper sqlHelper = new SQLHelper("localhost",
			3306, "db_onlinenote", "root", "aihejuhuacha");
	UserManager userMgr = new UserManager(sqlHelper);

	@Test
	public void testAddUser() {
		UserInfo ui = new UserInfo();
		ui.setUsername("Toy");
		ui.setNickname("Toy");
		ui.setPassword("pwd");
		ui.setSecQuestion("11");
		ui.setSecAnswer("33");
		ui.setRegisterTime("22");
		userMgr.addUser(ui);
		
		boolean ret = userMgr.hasUser("Toy");
		assertEquals(true, ret);
	}

	@Test
	public void testDelUser() {
		boolean ret = userMgr.delUser("Mason");
		assertEquals(true, ret);
	}

	@Test
	public void testResetPassword() {
		userMgr.resetPassword("Toy", "password");
	}

	@Test
	public void testModifyUser() {
		UserInfo ui = new UserInfo();
		ui.setUsername("Toy");
		ui.setNickname("Steven Toy");
		
		userMgr.modifyUser(ui);
	}

}
